import fs = require("fs")
import path = require("path")
import { Logger } from "../utils/Logger";

export class Config {

    public static Web_Client_Port: number;
    public static WebPortList:Array<number> = [];
    public static AndroidUrl:string=""
    public static IOSUrl:string = "";
    public static ipaUrl:string = "";

    public static preload(configPath: string) {
        return new Promise((resolve, reject) => {
            fs.readFile(configPath, (err, data: Buffer) => {
                if (err) throw err;
                let obj: Object = JSON.parse(data.toString());
                this.initConfig(obj);
                resolve();
            });
        });
    }

    private static initConfig(obj: Object) {
        Config.Web_Client_Port = obj["Web_Client_Port"];
        Config.WebPortList = obj["WebPortList"]
        Config.AndroidUrl = obj["AndroidUrl"]
        Config.IOSUrl = obj["IOSUrl"]
        Config.ipaUrl = obj["ipaUrl"]
    }
}